/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fsktms.packetmanager;

import fsktms.IPacket;
import java.io.IOException;
import java.net.Socket;
import java.nio.ByteBuffer;

/**
 *
 * @author salm
 */
public class PacketFactory
{
    public static IPacket createStartPacket(final int index, int magicKey)
    {
        return new Packet(0, index, ByteBuffer.allocate(4).putInt(magicKey).array());
    }
    
    public static IPacket createEndPacket(final int index)
    {
        return new Packet(2, index,  new byte[0]);
    }
    
    public static IPacket createChunkPacket(byte[] data, int index)
    {
        return new Packet(1, index, data);
    }
    
    public static IPacketManager createPM(Socket sk) throws IOException
    {
        return new PacketManagerImpl(sk);
    }
    
    public static IPacket createPingPacket()
    {
        return new Packet(4, 0,  new byte[0]);
    }
}
